/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.tastefuljava.hiketools.geo;

import java.util.Date;

public class Mn03Point {
    private double x;
    private double y;
    private double h;
    private Date time;

    public static Mn03Point fromWGS84(double lat, double lon, double ele,
            Date time) {
        lat = lat*0.36-16.902866;
        lon = lon*0.36-2.67825;
        double lat2 = lat*lat;
        double lat3 = lat2*lat;
        double lon2 = lon*lon;
        double lon3 = lon2*lon;
        double x = 600072.37
                + 211455.93*lon
                - 10938.51*lon*lat
                - 0.36*lon*lat2
                - 44.54*lon3;
        double y = 200147.07
                + 308807.95*lat
                + 3745.25*lon2
                + 76.63*lat2
                - 194.56*lon2*lat
                + 119.79*lat3;
/*
        double h = ele - 49.55
                + 2.73*lon
                + 6.94*lat;
 */
        double h = ele;
        return new Mn03Point(x, y, h, time);
    }

    public Mn03Point(double x, double y, double h, Date time) {
        this.x = x;
        this.y = y;
        this.h = h;
        this.time = time;
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    public double getH() {
        return h;
    }

    public Date getTime() {
        return time;
    }

    public TrackPoint toWGS84() {
        return TrackPoint.fromMn03(x, y, h, time);
    }
}
